/*
 * sequence.h
 *
 *  Created on: Mar 24, 2011
 *      Author: cookiemouse
 */

#ifndef SEQUENCE_H_
#define SEQUENCE_H_
#include<iostream>
#include<ostream>
#include<vector>
#include<set>
#include<sstream>
#include "pattern.h"

using namespace std;
#ifndef SEQUENCE_H
#define SEQUENCE_H

class sequencenode{
   int x;
   int y;

  public:
    int t;
    sequencenode(){
        this->x = 0;
        this->y = 0;
        this->t = 0;
    }
    sequencenode(int x, int y, int t){
       this->x = x;
       this->y = y;
       this->t = t;
    }
    sequencenode(const sequencenode& other){
       this->x = other.x;
       this->y = other.y;
       this->t = other.t;
    }


    friend ostream& operator<< (ostream& ios, sequencenode node){
         ios<<"("<<node.x<<","<<node.y<<")"  ;
         if (node.t!=-1){
             ios<<node.t;
         }
         return ios;
    }
    PatternNode toPatternNode(bool alongwitht=false){
          PatternNode node;
         if (alongwitht){
           node= PatternNode(x, y, t);
         }else {
            node = PatternNode(x, y, -1);
         }
         return node;
    }
};

class sequence {
    string  TID;
	vector< sequencenode > slist;
    string strpresent;
  public:
    sequence(){
         strpresent = "";
    }
	void addSequenceNode(sequencenode &node){
       slist.push_back(node);
    };
	sequencenode at(int index){
        return slist.at(index);
    };
	int	length(){
        return slist.size();
    };

   string tostring(){
       if (this->strpresent!=""){
          return strpresent;
       } else {
          for (int i=0; i<length();i++){
            stringstream ss ;
            string t;
            ss<<(slist.at(i));
            ss>>t;
            strpresent+= t;
          }
        }
        return strpresent;
    }
	bool complyWith(Pattern &pattern){
         if (pattern.length()>0){
           string ss = tostring();
           //cout<< ss<< ";" <<pattern.tostring() << ss.find(pattern.tostring())<< endl;
           if (ss.find(pattern.tostring())<ss.length()){
              return true;
           } else {
             return false;
           }
         }
         return false;
    }
};
#endif


#endif /* SEQUENCE_H_ */
